package com.ckerchina.admin.ckadmin.controller.console;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ckerchina.admin.ckadmin.controller.dto.MgrResponseData;
import com.ckerchina.admin.ckadmin.dao.AgentUserDao;
import com.ckerchina.admin.ckadmin.domain.AgentUser;
import com.ckerchina.admin.ckadmin.service.UpdateService;
import com.ckerchina.admin.ckadmin.utils.Page;


@Controller
public class AgentUserController extends AbstractConsoleController{

	@Autowired
	private AgentUserDao industryInfoDao;
	@RequestMapping("agentuser/list")
	public @ResponseBody Page<AgentUser> list(String agentName, int start, int limit){
		String where = "";
		Map<String, Object> params = new HashMap<String, Object>();
		if(!"".equals(agentName)){
			where += " and agentName = :agentName";
			params.put("agentName", agentName);
		}
		
		return industryInfoDao.findPage(where, params, start, limit, " order by createTime desc");
	}
	@Autowired
	UpdateService updateService;
	@RequestMapping("agentuser/add")
	public @ResponseBody MgrResponseData add(AgentUser finfo){	 
		updateService.addAgentUser(finfo);
		return new MgrResponseData("新增成功");
	}
	@RequestMapping("agentuser/update")
	public @ResponseBody MgrResponseData update(AgentUser finfo){
		updateService.updateAgentUser(finfo);
		return new MgrResponseData("修改成功");
	}
}
